/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ProductValues.java
 *
 * Created on 23.01.2012, 21:24:05
 */
package promogui;

import java.awt.ComponentOrientation;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.text.DecimalFormat;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;

/**
 *
 * @author Friedemann Metzger
 */




public class ProductValues extends javax.swing.JPanel {
    
    
        class nextWeek extends AbstractAction {

        public nextWeek() {
          super("Home", new ImageIcon("next.png"));
          putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('H',
              Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
          putValue(SHORT_DESCRIPTION, "Projekte Übersicht");
        }

        public void actionPerformed(ActionEvent e) {
            setValues(++currentWeek);
        }
      }
    
        class previousWeek extends AbstractAction {

        public previousWeek() {
          super("Home", new ImageIcon("previous.png"));
          putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('H',
              Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
          putValue(SHORT_DESCRIPTION, "Projekte Übersicht");
        }

        public void actionPerformed(ActionEvent e) {
            setValues(--currentWeek);
        }
      }
        

     int        weekCount, currentWeek;
     Project    project;
     AbstractAction next, previous;
     
     
    /** Creates new form ProductValues */
    public ProductValues(Project project) 
    {
    
        
        initComponents();
        this.project = project;
        
        next = new nextWeek();
        previous = new previousWeek();
        
        weekCount = project.getProductDataCurrentWeek() - 1;
        setValues(weekCount);
        
        
           
        toolBar.add(previous);
        toolBar.add(next);
        toolBar.setAlignmentY(CENTER_ALIGNMENT);
        
        
        
        
        
    }
    
    private void setValues(int week)
    {
    
      currentWeek = week;
      weekCount = project.getProductDataCurrentWeek() - 1;
        
    if (week == 0)
        previous.setEnabled(false);
    else
         previous.setEnabled(true);
    
    if (week == weekCount)
    {
        next.setEnabled(false);
        jLabel1.setText("Aktuelle Woche");
    }    
    else
    {
        next.setEnabled(true);
        jLabel1.setText("Woche "+ (week+1));
    }
    
    
    
    
    DecimalFormat formater = new DecimalFormat("        ");

        
 
    
    
    
   
    
    
    
    LOCOut.setText(String.format("%7d",project.getLinesOfCode().get(week)));
        
        bugCountOut.setText(String.format("%4d",project.getNumberOfBugs().get(week)).toString());
       
        double val = project.getPercentageOfCodeCoverage().get(week).doubleValue();
        
        codePercentOut.setText(String.format("%4.2f",val));
        
        
        componentCountOut.setText(String.format("%7d",project.getNumberOfComponents().get(week)));
        
        val = project.getPercentageOfSuccessfulTests().get(week).doubleValue();
                
        testPercentOut.setText(String.format("%4.2f", val));
        testCountOut.setText(String.format("%7d",project.getNumberOfTestCases().get(week)).toString());
        taskCountOut.setText(String.format("%7d",project.getNumberOfTasks().get(week)).toString());
    
    
    
    }
    
    
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        bugCount = new javax.swing.JLabel();
        componentCount = new javax.swing.JLabel();
        testCount = new javax.swing.JLabel();
        codePercent = new javax.swing.JLabel();
        testCountOut = new javax.swing.JLabel();
        testPercentOut = new javax.swing.JLabel();
        codePercentOut = new javax.swing.JLabel();
        componentCountOut = new javax.swing.JLabel();
        bugCountOut = new javax.swing.JLabel();
        LOCOut = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        taskCountOut = new javax.swing.JLabel();
        taskCount = new javax.swing.JLabel();
        toolBar = new javax.swing.JToolBar();
        testCount1 = new javax.swing.JLabel();
        codePercent1 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setLayout(new java.awt.GridBagLayout());

        bugCount.setText("Number of Bugs:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(bugCount, gridBagConstraints);

        componentCount.setText("Number of Components:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(componentCount, gridBagConstraints);

        testCount.setText("Number of TestCases:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(testCount, gridBagConstraints);

        codePercent.setText("Lines of Code:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(codePercent, gridBagConstraints);

        testCountOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        testCountOut.setText("testcases");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(testCountOut, gridBagConstraints);

        testPercentOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        testPercentOut.setText("testpercent");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(testPercentOut, gridBagConstraints);

        codePercentOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        codePercentOut.setText("code%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(codePercentOut, gridBagConstraints);

        componentCountOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        componentCountOut.setText("componentnumber");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(componentCountOut, gridBagConstraints);

        bugCountOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        bugCountOut.setText("bugcount");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(bugCountOut, gridBagConstraints);

        LOCOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        LOCOut.setText("locout");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(LOCOut, gridBagConstraints);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel1.setText("Produktdaten");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 15, 0);
        add(jLabel1, gridBagConstraints);

        taskCountOut.setFont(new java.awt.Font("Courier New", 1, 14)); // NOI18N
        taskCountOut.setText("tasknumber");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 10);
        add(taskCountOut, gridBagConstraints);

        taskCount.setText("Number of Tasks:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(taskCount, gridBagConstraints);

        toolBar.setFloatable(false);
        toolBar.setBorderPainted(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.insets = new java.awt.Insets(30, 0, 0, 0);
        add(toolBar, gridBagConstraints);

        testCount1.setText("Successfull tested (%):");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(testCount1, gridBagConstraints);

        codePercent1.setText("Code coverage (%):");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 10);
        add(codePercent1, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel LOCOut;
    private javax.swing.JLabel bugCount;
    private javax.swing.JLabel bugCountOut;
    private javax.swing.JLabel codePercent;
    private javax.swing.JLabel codePercent1;
    private javax.swing.JLabel codePercentOut;
    private javax.swing.JLabel componentCount;
    private javax.swing.JLabel componentCountOut;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel taskCount;
    private javax.swing.JLabel taskCountOut;
    private javax.swing.JLabel testCount;
    private javax.swing.JLabel testCount1;
    private javax.swing.JLabel testCountOut;
    private javax.swing.JLabel testPercentOut;
    private javax.swing.JToolBar toolBar;
    // End of variables declaration//GEN-END:variables








}
